<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="../vendor/font-awesome/css/font-awesome.min.css">
    <!-- Custom Font Icons CSS-->
    <link rel="stylesheet" href="../css/font.css">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="../css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="../css/custom.css">
    <link rel="stylesheet" href="../css/layer.css">
    <link rel="stylesheet" href="../bootstrap/css/bootstrap-switch.min.css">
    <title>查看用户</title>
</head>
<body>
<header class="header">
    <nav class="navbar navbar-expand-lg">
        <div class="search-panel">
            <div class="search-inner d-flex align-items-center justify-content-center">
                <div class="close-btn">Close <i class="fa fa-close"></i></div>
                <form id="searchForm" action="#">
                    <div class="form-group">
                        <input type="search" name="search" placeholder="What are you searching for...">
                        <button type="submit" class="submit">Search</button>
                    </div>
                </form>
            </div>
        </div>
        <div class="container-fluid d-flex align-items-center justify-content-between">
            <div class="navbar-header">
                <!-- Navbar Header--><a href="home.jsp" class="navbar-brand">
                <div class="brand-text brand-big visible text-uppercase"><strong
                        class="text-primary">小标</strong><strong>会议平台</strong></div>
                <div class="brand-text brand-sm"><strong class="text-primary">X</strong><strong>B</strong></div>
            </a>
                <!-- Sidebar Toggle Btn-->
                <button class="sidebar-toggle"><i class="fa fa-long-arrow-left"></i></button>
            </div>
            <div class="right-menu list-inline no-margin-bottom">
                <!-- Log out -->
                <div class="list-inline-item logout">
                    <a id="logout" href="../index.jsp" class="nav-link"><span class="d-none d-sm-inline">Logout </span></a>
                </div>
            </div>
        </div>
    </nav>
</header>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <%@include file="../assets/navJSP.jsp"%>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">用户列表</h2>
            </div>
        </div>
        <section class="no-padding-bottom">
            <div class="title">
                <form class="form-inline" action="/user/findUserMessage">
                    <div class="form-group">
                        <label for="inlineFormInput" class="sr-only">Name</label>
                        <input id="inlineFormInput" type="text" placeholder="按名字查找" class="mr-sm-3 form-control"
                               name="realName">
                    </div>
                    <div class="form-group">
                        <input type="submit" value="查询" class="btn btn-primary">
                    </div>
                </form>

            </div>
            <div class="table-responsive">
                <table class="table">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>年龄</th>
                        <th>简介</th>
                        <th>操作</th>
                        <th>加关注</th>
                    </tr>
                    </thead>
                    <tbody>

                    <C:forEach items="${pageData.data}" var="data">
                        <tr>
                            <th scope="row">${data.id}</th>
                            <td>${data.realName}</td>
                            <td>
                                <C:if test="${data.gender==1}">
                                    女
                                </C:if>
                                <C:if test="${data.gender==1}">
                                    男
                                </C:if>
                                <C:if test="${data.gender==null} or ${data.gender== \"\"} ">
                                    未知
                                </C:if>
                            </td>
                            <td>${data.age}</td>
                            <td>${data.desc}</td>
                            <td>
                                <button  name="${data.id}" style="background-color: red" class="userDetail">详细信息</button>
                                <%--<input type="submit" name="${data.id}" value="详细信息" class="btn-xs btn-primary userDetail">--%>
                            </td>

                            <td>
                                <C:if test="${data.id==sessionScope.user.id}">
                                    <p>我自己</p>
                                    <%--<input type="checkbox" value="" class="checkbox-template" disabled="true">--%>
                                </C:if>
                                <C:if test="${data.id!=sessionScope.user.id}">
                                    <input type="checkbox" value="" class="checkbox-template">
                                </C:if>
                                <%--<C:forEach items="${sessionScope.allMyFocus}" var="focus">--%>
                                    <%--<C:if test="${data.id==focus.id}">--%>
                                        <%--<p>已关注</p>--%>
                                    <%--</C:if>--%>
                                <%--</C:forEach>--%>
                            </td>
                        </tr>
                    </C:forEach>

                    </tbody>
                </table>

                <nav class="text-center" aria-label="Page navigation">
                    <ul class="pagination">
                        <li>
                            <a href="#" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <C:forEach begin="${requestScope.pageData.startPage}"
                                   end="${requestScope.pageData.endPage}"
                                   varStatus="i">
                            <li><a href="/user/findUserMessage?currPage=${i.count}">${i.count}</a>
                            </li>
                        </C:forEach>
                        <li>
                            <a href="#" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </section>

        <footer class="footer">
            <div class="footer__block block no-margin-bottom">
                <div class="container-fluid text-center">
                    <p class="no-margin-bottom">Copyright &copy; 2019.Company <a href="#">东方标准</a></p>
                </div>
            </div>
        </footer>
    </div>
</div>

<!-- JavaScript files-->
<script src="../vendor/jquery/jquery.min.js"></script>
<script src="../vendor/popper.js/umd/popper.min.js"></script>
<script src="../vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="../bootstrap/js/bootstrap-switch.min.js"></script>
<script src="../vendor/jquery.cookie/jquery.cookie.js"></script>
<script src="../vendor/chart.js/Chart.min.js"></script>
<script src="../js/layer.js"></script>
<script src="../vendor/jquery-validation/jquery.validate.min.js"></script>
<script src="../js/charts-home.js"></script>
<script src="../js/front.js"></script>
<script src="../js/custom.js"></script>


<script>
    var myCheckbox=document.querySelectorAll(".myCheckbox");
    for(var i=0;i<myCheckbox.length;i++){
        myCheckbox[i].addEventListener("click",function (evt) {
                var str=this.id;
                console.log(str);
                $.ajax({
                    url: "/user/addFocus",
                    ype: "post",
                    data:{userId:${sessionScope.user.id},foucsId:str}
                })
        })
    }
    var userDetail=document.querySelectorAll(".userDetail");
    for (var i=0;i<userDetail.length;i++){
        userDetail[i].addEventListener("click",function (evt) {
            var str=this.name;
            window.location.href = '../user/userMessage?MessageId='+str;
        })
    }
</script>
</body>
</html>